<?php namespace Admin\Controller;
/*
 * 网站管理控制器
 * @shuffling 轮播 实例化轮播模型
 * */
 	class WebsetController extends CommonController
 	{
 		protected $shuffling;
 		public function __init()
		{
			$this->shuffling = new \Common\Model\shuffling;
		}
		/*
		 * 轮播
		 * */
		public function lunbo()
		{
			$data = $this->shuffling->get();
			View::with("data",$data);
			View::make();
		}
		
		/*
		 * 添加轮播
		 * */
		public function addlunbo()
		{
			if(IS_POST){
				if(!$this->shuffling->addlunbo()){
					View::error($this->shuffling->getError());
				}else{
					View::success("添加成功",U('lunbo'));
				}
			}
			
			View::make();
		}
		/*
		 * 编辑轮播
		 * */
		public function resetlunbo(){
			//获得get参数
			$lun_id = Q("get.lun_id",0,"intval");
			if(IS_POST){
				if(!$this->shuffling->resetlunbo($lun_id)){
					View::error($this->shuffling->getError());
				}else{
					View::success("编辑成功",U("lunbo"));
				}
			}
			//获得元数据
			$olddata = $this->shuffling->where("lun_id",$lun_id)->first();
			//p($olddata);die;
			View::with("olddata",$olddata);
			View::make();
		}
		/*
		 * 删除轮播
		 * */
		public function dellunbo()
		{
			$lun_id = Q("get.lun_id",0,"intval");
			if(!$this->shuffling->del($lun_id)){
				View::error($this->shuffling->getError());
			}else{
				View::success("删除成功",U("lunbo"));
			}
		}
 	}
